#pragma once
#ifndef ControlTable_H
#define ControlTable_H

#include "headers.h"

enum Action { SHIFT, GOTO, REDUSE, ACCEPT, ERROR };

struct Cell
{
    int action;    
    int value;//newState for SHIFT rules, number of rule for REDUSE rules. otherwise ignored
    Cell()
    {
        action=ERROR;
        value=0;
    }
    Cell(int actionParam, int valueParam)
    {
        action=actionParam;
        value=valueParam;
    }
    QString ToString()
    {
        switch(action)
        {
        case SHIFT:
            return QObject::tr("S-%1").arg(value);
        case GOTO:
            return QObject::tr("%1").arg(value);
        case REDUSE:
            return QObject::tr("R-%1").arg(value);
        case ACCEPT:
            return "ACC";
        case ERROR:
            return "";
        }
        return "Incorrect action Cellalue";
    }
};

class ControlTable
{
public:
    ControlTable(QList<int>, QList<QString >);
    ~ControlTable();
    int SetValue(int, QString , Cell);
    int GetValue(int, QString , Cell*) const;
    int GetWidth() const;
    int GetHeight() const;
    QList<int> keys1() const;
    QList<QString > keys2() const;
    QStringList keys1string() const;
private:
    QMap<int, int> TranslatorK1;
    QMap<QString , int> TranslatorK2;
    Cell** values;
};

#endif // ControlTable_H
